package com.xm.servlet.background.orders;

import com.google.gson.Gson;
import com.xm.service.background.LogisticsStationService;
import lombok.SneakyThrows;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 根据物流公司获取
 *
 * @author 康文程
 * @date 2024-1-11
 */
@WebServlet("/background/logistics/stations")
public class GetLogisticsStationsByLogisticsCompanyIdServlet extends HttpServlet {
    /**
     * 物流站
     */
    private final LogisticsStationService service = new LogisticsStationService();

    @SneakyThrows
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
        String logisticsCompaniesId = req.getParameter("logisticsCompaniesId");
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().print(new Gson().toJson(service.
                getLogisticsStationsByLogisticsCompanyId(
                        Integer.parseInt(logisticsCompaniesId))));
    }
}
